package com.ms.p2p.template.directive;


import com.alibaba.dubbo.config.annotation.Reference;
import com.ms.p2p.bean.PageBean;
import com.ms.p2p.entity.content.Advert;
import com.ms.p2p.provider.AdvertProvider;
import freemarker.core.Environment;
import freemarker.template.TemplateDirectiveBody;
import freemarker.template.TemplateException;
import freemarker.template.TemplateModel;
import org.springframework.stereotype.Repository;

import java.io.IOException;
import java.util.List;
import java.util.Map;

/**
 * Created by xing_ on 2017/5/21.
 */
@Repository
public class BannerDirective extends BaseDirective {

    @Reference
    private AdvertProvider advertProvider;

    @Override
    public void execute(Environment env, Map map, TemplateModel[] templateModels,
                        TemplateDirectiveBody body) throws TemplateException, IOException {
        PageBean pageBean =new PageBean();
        pageBean.setPageSize(null);
        List<Advert> list = advertProvider.getPPTList(1,1);
        renderParamToBody(OUT_LIST, list, env, body);
    }
}
